﻿/**
 *
 * @file FITKAbaqusHDF5AdaptorBoundary.h
 * @brief 读写HDF5文件的Boundary类
 * @author fulipeng (fulipengqd@yeah.net)
 * @date 2024-06-11
 *
 */
#ifndef  _FITKABAQUSHDF5ADAPTORBOUNDARY_H__
#define  _FITKABAQUSHDF5ADAPTORBOUNDARY_H__

#include "FITKAbaqusIOHDF5API.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITK_Interface/FITKInterfaceIOHDF5/FITKInterfaceHDF5AdaptorBoundaryLocation.h"


 //前置声明
ForwardDeclarNS(Interface, FITKAbaAbstractBoundaryCondition)
ForwardDeclarNS(Interface, FITKAbaBoundaryConditionDisplacement)
ForwardDeclarNS(Interface, FITKAbaBoundaryConditionSymmetry)
ForwardDeclarNS(AbaqusData, FITKDataCase)

namespace IO
{
    /**
     * @brief HDF5 Boundary 读写适配器
     * @author fulipeng (fulipengqd@yeah.net)
     * @date 2024-06-07
     */
    class FITKABAQUSIOHDF5API FITKAbaqusHDF5AdaptorBoundary : public FITKInterfaceHDF5AdaptorBoundaryLocation
    {
    public:
        explicit FITKAbaqusHDF5AdaptorBoundary() = default;
        virtual ~FITKAbaqusHDF5AdaptorBoundary() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        QString getAdaptorClass() override;

        /**
         * @brief 设置数据结构
         * @param caseData 算例数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        void setDataCase(AbaqusData::FITKDataCase* caseData);

        /**
         * @brief 适配器读取
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool adaptW() override;

    protected:

        /**
         * @brief 读取 边界条件
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        virtual bool readBoundaryCondition(Interface::FITKAbaAbstractBoundaryCondition* bc, H5::Group& h5Group);

        /**
         * @brief 读取 位移
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readDisplacement(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

        /**
         * @brief 读取 对称
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readSymmetry(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

        /**
         * @brief 读取 速度、角速度
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-07-09
         */
        bool readVelocity(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

        /**
         * @brief 写出 边界条件
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        virtual bool writeBoundaryCondition(Interface::FITKAbaAbstractBoundaryCondition* bc, H5::Group& h5Group);

        /**
         * @brief 读取 位移
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeDisplacement(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

        /**
         * @brief 写出 对称
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeSymmetry(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

        /**
         * @brief 写出 速度、角速度
         * @param bc 边界条件
         * @param h5Group 数据块
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-07-09
         */
        bool writeVelocity(Interface::FITKAbaAbstractBoundaryCondition* bc, int stepID, H5::Group& h5Group);

    private:

        /**
         * @brief 算例数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        AbaqusData::FITKDataCase* _caseData{};

    };

    Register2FITKIOAdaptorFactory(HDF5, Interface::FITKAbaAbstractBoundaryCondition, FITKAbaqusHDF5AdaptorBoundary)

}

#endif
